export default {
  namespaced: true,
  state: () => ({
    // 用户信息对象
    userInfo: JSON.parse(uni.getStorageSync('userInfo') || '{}'),
    token:uni.getStorageSync('token')||"",
  }),
  mutations: {
    updataUserInfo(state, userInfo) {
      state.userInfo = userInfo
      this.commit('user/saveUserInfoStorage')
    },
    saveUserInfoStorage(state) {
      uni.setStorageSync('userInfo', JSON.stringify(state.userInfo))
    },
    // 存储tokem
   updateToken(state,token){
     state.token=token
     this.commit('user/saveTokenToStorage')
   },
   // 把token存储到本地
   saveTokenToStorage(state){
     uni.setStorageSync('token',state.token)
   }
  }
}
